/**
 * 
 */
package db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.catalina.Context;

/**
 * @author Teja
 * 
 */
public class DatabaseBean {

	private static final String url = "jdbc:mysql://localhost:3306/";
	private static final String dbName = "movietixdb";
	private static final String driver = "com.mysql.jdbc.Driver";
	private static final String username = "root";
	private static final String password = "pass";

	private Statement stmt;

	public DatabaseBean() {

		try {
			Class.forName(driver).newInstance();
			Connection con = DriverManager.getConnection(url + dbName, username,
					password);
			System.out.println("init stmt/n");	
			this.stmt = con.createStatement();

		} catch (ClassNotFoundException e) {
			System.out.println("could not find jdbc driver");
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @return the stmt
	 */
	protected Statement getStmt() {
		return stmt;
	}

	/**
	 * @param stmt
	 *            the stmt to set
	 */
	protected void setStmt(Statement stmt) {
		this.stmt = stmt;
	}

	/*
	 * public static void main(String args[]) { DatabaseBean bean = new
	 * DatabaseBean(); bean.DoesUsernameExistInDB("teja"); }
	 */
}
